using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_CommonTitleValue : UIBaseNode
    {

        #region Template Generate,don't modify
        protected partial class UIB_UIN_CommonTitleValue
        {
            #region ObjectBinding Generate 
            public IQIGame.Onigao.Framework.ExText textTitle { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textValue { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textTitle", out var __tbv0);
                this.textTitle = __tbv0;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textValue", out var __tbv1);
                this.textValue = __tbv1;
            }

            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region fields & properties
        protected UIB_UIN_CommonTitleValue ui { get; set; }
        #endregion

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_CommonTitleValue();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {

        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        public void Show(string strValue, string strTitle = null)
        {
            this.Show();
            this.SetTitle(strTitle);
            this.SetValue(strValue);
        }

        void SetTitle(string str, bool isActive = true)
        {
            if (this.ui.textTitle == null)
                return;
            this.ui.textTitle.SetActive(isActive);
            if (isActive && str != null)
            {
                this.ui.textTitle.text = str;
            }
        }

        void SetValue(string str, bool isActive = true)
        {
            if (this.ui.textValue == null)
                return;
            this.ui.textValue.SetActive(isActive);
            if (isActive && str != null)
            {
                this.ui.textValue.text = str;
            }
        }

        public void SetState(int state)
        {
            this.SetTitleState(state);
            this.SetValueState(state);
        }

        void SetTitleState(int state)
        {
            if (this.ui.textTitle == null)
                return;

            //this.ui.textTitle.indexSwitchColor = state;
        }

        void SetValueState(int state)
        {
            if (this.ui.textTitle == null)
                return;
            //this.ui.textValue.indexSwitchColor = state;
        }

        protected override void OnDispose()
        {

        }
    }
}
